package com.ziyun.job.modules.job.task.seller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.ziyun.erp.modules.order.service.ErpOrderService;
import com.ziyun.erp.modules.order.service.OrderInfoService;
import com.ziyun.erp.modules.supp.entity.SellerInfoEntity;
import com.ziyun.erp.modules.supp.service.SellerInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author llc
 * @Description: 门店订单信息同步到order_info表中
 * @date 2018-10-19 10:49
 */
@Slf4j
@Component("SynSellerErpOrderToOrderInfoTask")
public class SynSellerErpOrderToOrderInfoTask {
    @Autowired
    private OrderInfoService orderInfoService;
    @Autowired
    private ErpOrderService erpOrderService;
    @Autowired
    private SellerInfoService sellerInfoService;

    /**
     * 门店订单信息同步到order_info表中
     */
    public void synSellerErpOrderToOrderInfo(){
        // 查询所有自营门店
        List<SellerInfoEntity> sellerInfoEntityList = sellerInfoService.selectList(new EntityWrapper<SellerInfoEntity>()
                .eq("self", 1)
                .eq("disabled", 0)
        );

        for(SellerInfoEntity sellerInfoEntity :sellerInfoEntityList){
            if(sellerInfoEntity.getSellerId() == 1 || sellerInfoEntity.getSellerId() == 18 || sellerInfoEntity.getSellerId() == 20 ){
                continue;
            }
            log.info("========== 紫云门店订单：" + sellerInfoEntity.getSellerName() + " ,同步信息到order_info 开始 ========== ");

            erpOrderService.synErpOrderToOrderInfo(sellerInfoEntity.getSellerId());

            log.info("========== 紫云门店订单:" + sellerInfoEntity.getSellerName() + " ,同步信息到order_info 结束 ========== ");
        }
    }
}
